You are currently viewing Programming Basics #33 Iterating Through Collections

Programming Basics #33 Iterating Through Collections

  • Post author:
  • Post category:Videos

http://learn-share.net/programming-basics-course/
Programming Course. The Basics of Programming.
#33 Iterating Through Collections

Learn to code.

Iterating through collections

Arrays is one of the most common things you find in all programer languages. But don’t think to much in the word array, but think in the wider idea in collections.

You can think on the quantity of applications you have in your computer that are really a collection of things.

The email program, is a collection of emails. Your address book, is a collection of contacts.

One of the most common things you ever need to do, it’s to iterate thru, or loop thru ever element in an array.

Let’s take a look on how we do this.

So i have a simple array with five elements, and i’m going to setup a basic loop to go thru this.

Creating a while loop, we could do a for loop as well.

Now we need to setup the index. And it’s very important, when you working with basic array, you start the index at zero. Because is zero based.

Then we do the usual check condition. You don’t need to know much about the array here, you are just asking, what it’s length.

And since this is a loop, so at the end of the body of the loop, we want to increment that index.

http://learn-share.net/programming-basics-course/